
/* model */
import { ConnectorFormValue } from '@src/modules/connector/model/form/common'
/* types */
import {
  ConnectorFormValueCustomerAddressType,
  ConnectorServerValueCustomerAddressType
} from '@src/modules/connector/types'


class ConnectorFormValueCustomerAddress extends ConnectorFormValue {
  
  // 表单数据 -> 服务器数据
  formValueToServerValue(formValue: ConnectorFormValueCustomerAddressType): ConnectorServerValueCustomerAddressType {
    
    const id = formValue?.id || ''
    const name = formValue?.address || ''
    
    return {
      id,
      name
    }
    
  }
  
  // 服务器数据 -> 表单数据
  serverValueToFormValue(serverValue: ConnectorServerValueCustomerAddressType): ConnectorFormValueCustomerAddressType[] {
    
    const id = serverValue?.id || ''
    const address = serverValue?.name || ''
    
    return [{
      id,
      address,
    }]
    
  }
  
}

export default ConnectorFormValueCustomerAddress